<?php
include 'DBconn.php';
class CurrencyMaster{
     public function addNewCurrency($VObject)
     {
      $query="INSERT INTO currency_header(currency_country, currency_name, currency_symbol, currency_code, currency_value, cre_userid, cre_datetime, activestatus)VALUES ('$VObject->currency_country','$VObject->currency_name','$VObject->currency_symbol','$VObject->currency_code','$VObject->currency_value','$VObject->cre_userid','$VObject->cre_datetime',1)";
       $s=mysql_query($query) or die(mysql_error());
        if ($s=1) 
      {
        mysql_query("COMMIT");
      }
      else
      {
        mysql_query("ROLLBACK");
      }
      return $this->getAllCurrency();
    }
     public function getAllCurrency()
    {
        $result=mysql_query("SELECT * FROM currency_header WHERE activestatus ='1'") or die(mysql_error());
        $ret_arr=array();
        while($row=mysql_fetch_object($result))
        {
	$temp=new VoCurrency();
        $temp->serialnumber = (int)$row->serialnumber;
        $temp->currency_name=$row->currency_name;
        $temp->currency_country = $row->currency_country;
        $temp->currency_symbol = $row->currency_symbol;
        $temp->currency_code = $row->currency_code;
        $temp->currency_value =(double) $row->currency_value;
        $temp->cre_userid =(int)$row->cre_userid;
        $temp->cre_datetime = $row->cre_datetime;
        $temp->activestatus=(boolean)$row->activestatus;
        $ret_arr[]=$temp;
        }
        mysql_free_result($result);
        return $ret_arr;
    }

  public function editCurrencyDetails($VObject)
  {
    $query="update currency_header set currency_name='$VObject->currency_name',currency_country='$VObject->currency_country',currency_symbol='$VObject->currency_symbol',currency_code='$VObject->currency_code',currency_value='$VObject->currency_value',cre_userid='$VObject->cre_userid',cre_datetime='$VObject->cre_datetime' where serialnumber='$VObject->serialnumber'";
  $s=  mysql_query($query) or die(mysql_error());
   if ($s=1)
      {
        mysql_query("COMMIT");
      }
      else
      {
        mysql_query("ROLLBACK");
      }
       return $this->getAllCurrency();
  }
public function deleteUserDetails($VObject)
{
  $s= mysql_query("update currency_header set activestatus=0 where serialnumber=".$VObject->serialnumber) or die(mysql_error());
  if ($s=1)
      {
        mysql_query("COMMIT");
      }
      else
      {
        mysql_query("ROLLBACK");
      }
       return $this->getAllCurrency();
  }
}

class VoCurrency
{
    var $serialnumber;
    var $currency_country;
    var $currency_name;
    var $currency_symbol;
    var $currency_code;
    var $currency_value;
    var $cre_userid;
    var $cre_datetime;
    var $activestatus;
}

?>